package test;

import java.lang.reflect.*;


class TestReflect {
	private int t1;
	private int t2;
	private int t3;
	public void me() {
		System.out.println("me");
	}
	public int getT1() {
		System.out.println("do gT1");
		return t1;
	}
	public void setT1(int t1) {
		System.out.println("do sT1");
		this.t1 = t1;
	}
	public int getT2() {
		System.out.println("do gT2");
		return t2;
	}
	public void setT2(int t2) {
		System.out.println("do sT2");
		this.t2 = t2;
	}
	public int getT3() {
		System.out.println("do gT3");
		return t3;
	}
	public void setT3(int t3) {
		System.out.println("do sT3");
		this.t3 = t3;
	}
	public void getT3(int t3, int a) {
		System.out.println("do sT3a");
		this.t3 = t3;
	}
	public void getT3(int t3, int a, int b) {
		System.out.println("do sT3ab");
		this.t3 = t3;
	}
	
	private void privateMethod() {
		System.out.println("this is private");
	}
	
}
public class Reflection {
	public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, InstantiationException, SecurityException, NoSuchMethodException {
		Class cl = Class.forName("test.TestReflect");
		Object clobj = cl.newInstance();
		Method [] me = cl.getMethods();
		Method [] dme = cl.getDeclaredMethods();
		for (Method method : me) {
			if(method.toString().indexOf("set") != -1) {
				Object [] pa = new Object[] {2};
				method.invoke(clobj, pa);
			}
		}
		System.out.println("------------------------------------------------");
		for (Method method : me) {
			System.out.println(method.getName()+"::" + method.getGenericReturnType().toString());
		}
		System.out.println("------------------------------------------------");
		for (Method method : dme) {
			System.out.println(method.getName()+"::" + method.getGenericReturnType().toString());
		}
	}
}
